home *** CD-ROM | disk | FTP | other *** search
- #slipdial
- #--------------------------------------------------------------------
- # $Id: demon 1.5 95/05/25 16:13:30 root Exp Locker: root $
- #
- # Script: !SlipDial.Scripts.demon
- #
- # Script for calling Demon Internet Services.
- #
- # Credits: original R.W. Orwin 1994 (rob@wong.demon.co.uk)
- # sprites James Woodman (woody@bacchus.demon.co.uk)
- # new version Alan Fitch (alan@cycle.demon.co.uk)
- # mercury improvements Mike James (mike@hamble.demon.co.uk)
- # improved setting up Doug Macready (dougmac@newquay.zynet.co.uk)
- #
- # Maintained by Alan Fitch
- #
-
- call initMain
- call configure
- call setserial
- call makemenus
- call %provider
-
- #
- # main loop
- #
-
- :loop
- message /close
- wait /event
- goto loop
- exit
-
- # end of program
- #--------------------------------------------------------------------
-
- #====================================================================
- # SUBROUTINES
- #====================================================================
-
- # dial number 1 from the configuration file
- :dial1
- set nRetries 50
- set phonenum %phonenum1
- if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
- goto dodial
-
- # dial number 2 from the configuration file
- :dial2
- set nRetries 50
- set phonenum %phonenum2
- if (?ne %phonenum2 %nopredialnum) set phonenum %predial%phonenum2
- goto dodial
-
- # dial number 3 from the configuration file
- :dial3
- set nRetries 50
- set phonenum %phonenum3
- if (?ne %phonenum3 %nopredialnum) set phonenum %predial%phonenum3
- goto dodial
-
- # dial the number defined as local
- :diallocal
- set nRetries 50
- set phonenum %localnumber
- if (?ne %localnumber %nopredialnum) set phonenum %predial%localnumber
- goto dodial
-
- #-----------------------------------------------------------
- # Subroutine: List
- # Calls a list of phone numbers, specified below in the
- # variable 'phonenum'. Returns via subroutine dodial.
- # nRetries is the number of times SlipDial retries the number
- # if it is busy.
- # The number of retries is reduced compared to the other
- # menu items (which dial only one PoP) as the intention is to
- # to work through the list of numbers reasonably quickly.
- #-----------------------------------------------------------
-
- :List
- set nRetries 5
- set phonenum %phonenum1
- if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
- if (?ne %phonenum2 %nopredialnum) set phonenum "%phonenum %predial"
- set phonenum "%phonenum%phonenum2"
- if (?ne %phonenum3 %nopredialnum) set phonenum "%phonenum %predial"
- set phonenum "%phonenum%phonenum3"
- goto dodial
-
- #-----------------------------------------------------------
- # Subroutine: dodial
- # Note: has multiple entry points from "goto" statements
- # above. However it finally returns to the main waiting
- # loop.
- #-----------------------------------------------------------
-
- :dodial
-
- #
- # kill newsbase and ttfn if they are running, and were started from SlipDial
- #
- # Note that if they weren't started by SlipDial, SlipDial knows nothing
- # about them and will start another copy even if they are already running.
- #
-
- task /kill="Newsbase"
- task /kill="TTFN"
-
- # Claim the device driver
-
- if (!claim 3) return 0
-
- # initialise modem
-
- init
-
- # check if DSR and CTS are set
-
- if (?eq {?line/dsr} 0) goto no_dsr
- if (?eq {?line/cts} 0) goto no_cts
-
- # dial the number, return to main menu if failed.
-
- retry %nRetries 15
- if (!dial /nodial=5 /nocar=3 /busy=3 %phonenum) return 0
-
- #
- # arrive here if dial succeeded
- # get username/password prompts to authenticate self to server.
- # after each prompt, return to main menu if failed.
- #
-
- if (!wait /del=50 ogin:) goto no_login
- send %nodename
-
- if (!wait /del=20 word:) goto no_password
- send %password
-
- if (!wait /del=50 ocol:) goto no_protocol
- send %protocol
-
- message /capture="IP" /end="HELLO" /maxlines=7 /centre
- ipget 158.
- if (!wait /del=30 HELLO) return 0
-
- pause 5
- task /name="TCP/IP" <TCPIP2$dir>.!Run
-
- # watch out for carrier detect to go low
-
- alarm /dcd "goto good_finish"
- :loop2
- wait /event
- goto loop2
-
- #
- # Call has been finished successfully, so release the port
- #
-
- :good_finish
- task /kill="TCP/IP"
- message /close
- message "Call finished successfully" /centre
- release
-
- # now pause for 2 seconds to allow RISC OS to sort out the display.
-
- pause 2
-
- #
- # Start up TTFN and Newsbase.
- #
-
- if (!?task TTFN) task /name="TTFN" <TTFN$Dir>.!Run
- if (!?task NewsBase) task /name="Newsbase" <NewsBase$Dir>.!Run
- return 1
-
- #
- # Call failed in some way
- #
-
- :no_dsr
- message/wait "Modem not ready - DSR line is not set" "(Please close this window to continue)" /centre
- goto bad_finish
-
- :no_cts
- message/wait "Modem not ready - CTS line is not set" "(Please close this window to continue)" /centre
- goto bad_finish
-
- :no_login
- message "Call failed - timeout waiting for login prompt" /centre
- goto bad_finish
-
- :no_password
- message "Call failed - timeout waiting for password prompt" /centre
- goto bad_finish
-
- :no_protocol
- message "Call failed - timeout waiting for protocol prompt" /centre
- goto bad_finish
-
- :bad_finish
- pause 1
- release
- reinit
- return 0
-
- #-----------------------------------------------------------
- # Subroutine: Bt
- # Set the provider to BT
- #-----------------------------------------------------------
-
- :bt
- set provider bt
- icon /id="Mercury" /action="call bt" hgoff
- set predial ""
- message "service provider set to BT" /centre
- pause 1
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: Mercury
- # Set the provider to Mercury
- #-----------------------------------------------------------
-
- :mercury
- set provider Mercury
- icon /id="Mercury" /action="call mercury" hgon
- set predial %mercury_pin
- message "service provider set to Mercury" /centre
- pause 1
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: makemenus
- # Defines the menus for dialling etc. Note the length of
- # all the names must be less than 255 characters total, as
- # must the length of all the commands.
- #-----------------------------------------------------------
-
- :makemenus
- menu "%name1:call dial1" "%name2:call dial2" "%name3: call dial3" "List:call List"
- menu /icon="Mercury" "Mercury:call mercury" "BT:call bt" "Save Default:call saveconfig"
- menu /icon="Local" "Local call:call diallocal"
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: setserial
- # Set Serial Port/Driver Parameters
- #-----------------------------------------------------------
-
- :setserial
- driver %driver
- port %wport %prtnum
- speed %speed
- set protocol slip
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: setup1
- # Called to setup defaults if no configuration file present.
- #-----------------------------------------------------------
-
- :setup1
- input/prompt="Enter Serial Block Driver Name : " wport
- input/prompt="Enter Serial Port Number (if relevant) : " prtnum
- input/prompt="Enter Your Modem->Computer Speed (bps) : " speed
- input/prompt="Enter Your Demon Nodename : " nodename
- input/prompt="Enter Your Password : " password
- input/prompt="Enter Your Modem Driver Name (e.g. USR): " driver
- input/prompt="Enter Telephone Provider (BT/Mercury) : " provider
- input/prompt="Enter Your Mercury PIN : " mercury_pin
- input/prompt="Enter NAME of main number e.g. London : " name1
- input/prompt="Enter NUMBER of main number e.g. 01813384848 : " phonenum1
- input/prompt="Enter NAME of 2nd number : " name2
- input/prompt="Enter NUMBER 2nd number : " phonenum2
- input/prompt="Enter NAME of 3rd number : " name3
- input/prompt="Enter NUMBER of 3rd number : " phonenum3
- input/prompt="Enter nearest NUMBER, e.g. 01813384848 : " localnumber
- input/prompt="Enter your non-mercury number, e.g. 01813384848 : " nopredialnum
- :saveconfig
- set filename {?file/expand slipdial:demconfg}
- open/id=conf/write %filename
- write/id=conf %wport
- write/id=conf %prtnum
- write/id=conf %speed
- write/id=conf %nodename
- write/id=conf %password
- write/id=conf %driver
- write/id=conf %provider
- write/id=conf %mercury_pin
- write/id=conf %name1
- write/id=conf %phonenum1
- write/id=conf %name2
- write/id=conf %phonenum2
- write/id=conf %name3
- write/id=conf %phonenum3
- write/id=conf %localnumber
- write/id=conf %nopredialnum
- close/id=conf
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: configure
- # This loads password config from file or prompts for data
- # to create file.
- #-----------------------------------------------------------
-
- :configure
- set filename {?file/expand slipdial:demconfg}
- if (!?file %filename) call setup1
- open/read/id=conf/error="return" %filename
- read/id=conf/eof="goto closeconf" wport
- read/id=conf/eof="goto closeconf" prtnum
- read/id=conf/eof="goto closeconf" speed
- read/id=conf/eof="goto closeconf" nodename
- read/id=conf/eof="goto closeconf" password
- read/id=conf/eof="goto closeconf" driver
- read/id=conf/eof="goto closeconf" provider
- read/id=conf/eof="goto closeconf" mercury_pin
- read/id=conf/eof="goto closeconf" name1
- read/id=conf/eof="goto closeconf" phonenum1
- read/id=conf/eof="goto closeconf" name2
- read/id=conf/eof="goto closeconf" phonenum2
- read/id=conf/eof="goto closeconf" name3
- read/id=conf/eof="goto closeconf" phonenum3
- read/id=conf/eof="goto closeconf" localnumber
- read/id=conf/eof="goto closeconf" nopredialnum
- set provider {string /lower %provider}
- :closeconf
- close/id=conf
- return
-
- #-----------------------------------------------------------
- # Subroutine: initMain
- # General initialisation.
- #-----------------------------------------------------------
-
- :initMain
-
- # remove comment from following line for tracing
-
- #trace "SlipDial:logoutput"
- debug 3
- icon /file="SlipDial:DemonSpr"
- set mercury_pin ""
- icon /id="Local" /action="call diallocal" loc
- return 1
-
- # $Log: demon $
- # Revision 1.5 95/05/25 16:13:30 root
- # 1) re-wrote the script to have phone numbers set up in the config file.
- # 2) Check for errors on DSR and CTS added before dialling.
- # 3) More informative messages when a call fails
- #
- # Revision 1.4 95/05/08 01:23:57 root
- # modified startup of TTFN/NewsBase so they should only run if not
- # already running
- #
- # Revision 1.3 95/05/08 00:45:57 root
- # corrected minor errors with leeds and iow case of subroutine labels
- #
- # Revision 1.2 95/05/08 00:23:20 root
- # 1) updated to include changes suggested by Doug Macready, to improve mercury
- # support
- # 2) removed newsrate computation, as TCPIP2.04 now does this
- # 3) setup file renamed to demconfg so that it will be created anew when
- # people run this for the first time.
- #
- # Revision 1.1 95/05/07 23:31:02 root
- # Initial revision
- #
-
- --
- Alan Fitch
- Tel.: +44 (0)1703 472342 (voice)
- E-mail: alan@cycle.demon.co.uk
-
-
-
-
-